<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //// 1.
        // let a = 10
        // function foo() {
        //     console.log(a)
        //     let a = 20
        // }
        // foo()
        // // 2.
        var array = []
        for (var i = 0; i < 3; i++) {
            array.push(() => i)
        }
        var newArray = array.map(el => el())
        console.log(newArray)
        // // 3.
        // function foo() {
        //     return Promise.resolve().then(foo)
        // }
        // foo()
    </script>
</body>

</html>